--
module("UI.Windows.YiJianFanKuiWin", package.seeall)

local UIUtility = require("UI.Utility")
local UIWindow = require("UI.UIWindow").UIWindow
local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
local json = require("cjson")
YiJianFanKuiWin = UIWindow:new()

YiJianFanKuiWin.name = "YiJianFanKuiWin"


function YiJianFanKuiWin:Init()
    local t = self.Container.transform

    self.close_btn = UIUtility.GetChildTransform("close_btn", t, true)
    self:BindEvents()

    self.yijian_fankui_input = UIUtility.FindContorl("UIInput", "yijian_fankui_input", t)
    self.Confirm_btn = UIUtility.GetChildTransform("Confirm_btn", t, true)

    UIHelper.BindUIEvnet("Click", function()
         if self.yijian_fankui_input.value == "" then
            UIWinMgr:OpenTextNotice("请输入反馈内容")
            return
         end
         local _dataJson = string.format(
            '{"feedbackType": "反馈","content":"%s"}',
            self.yijian_fankui_input.value
        )
         
         require("NetWork.NetHttp").SendPostRequest_token("/byr/api/v1/feedback/add", function(ok, data)
            if ok then
                UIWinMgr:OpenTextNotice("反馈成功")
                self:Close(1)
            else
                UIWinMgr:OpenTextNotice("反馈失败")
            end
         end,_dataJson)
    end, self.Confirm_btn.gameObject)
 
end

function YiJianFanKuiWin:OnShow()

end

function YiJianFanKuiWin:OnClose()

end

function YiJianFanKuiWin:BindEvents()
    UIHelper.BindUIEvnet("Click", function()
        self:Close(1)
    end, self.close_btn.gameObject)
end
